package com.xzwk.yn.serveradmin;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import java.io.IOException;

public class IndexLaunch  {

    public static void launch(Stage rootStage, boolean closeRootStage) throws IOException {

        Stage stage = new Stage();

        stage.initStyle(StageStyle.DECORATED);
        stage.setWidth(900);
        stage.setHeight(600);
        stage.setTitle("xzwk");

        FXMLLoader fxmlLoader = new FXMLLoader(IndexLaunch.class.getResource("/fxml/index.fxml"));
        AnchorPane root  = fxmlLoader.load();
        Scene scene = new Scene(root);

        // 引入css

       List<String> cssList = new ArrayList<>();
       cssList.add(Objects.requireNonNull(IndexLaunch.class.getResource("/css/index.scss")).toExternalForm());
       //左侧菜单样式
       cssList.add(Objects.requireNonNull(IndexLaunch.class.getResource("/css/left.scss")).toExternalForm());
       scene.getStylesheets().addAll(cssList);
        stage.setScene(scene);
        stage.show();


        //如果需要关闭根窗体 则关闭
        if (closeRootStage){
            rootStage.close();
        }
    }

}